#include<stack>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
class Solution
{
public:
    bool isNumber(string& token) 
    {
        return !(token == "+" || token == "-" || token == "*" || token == "/");
    }

    int evalRPN(vector<string>& tokens)
    {
        stack<int> st;

        for (int i = 0; i < tokens.size(); i++)
        {
            if (isNumber(tokens[i]))
            {
                st.push(stoi(tokens[i]));
            }
            else if (tokens[i][0] == '+')
            {
                int left, right;
                right = st.top();
                st.pop();
                left = st.top();
                st.pop();
                st.push(left + right);
            }
            else if(tokens[i][0] == '-')
            {
                int left, right;
                right = st.top();
                st.pop();
                left = st.top();
                st.pop();
                st.push(left - right);
            }
            else if (tokens[i][0] == '*')
            {
                int left, right;
                right = st.top();
                st.pop();
                left = st.top();
                st.pop();
                st.push(right * left);
            }
            else if (tokens[i][0] == '/')
            {
                int left, right;
                right = st.top();
                st.pop();
                left = st.top();
                st.pop();
                st.push(left / right);
            }
        }

        return st.top();
    }
};

int main()
{
    Solution s1;

    vector<string> v{ "4","13","5","/","+" };
    s1.evalRPN(v);
    return 0;
}